import { CoolController, BaseController } from '@cool-midway/core';
import { PayPaymentEntity } from '../../entity/payment';
import { UserInfoEntity } from '../../../user/entity/info';
import { PayOrderEntity } from '../../entity/order';

/**
 * 支付模块-管理端支付记录控制器
 */
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: PayPaymentEntity,
  pageQueryOp: {
    keyWordLikeFields: ['a.paymentNo', 'a.thirdPartyNo'],
    fieldEq: ['a.userId', 'a.orderId', 'a.paymentMethod', 'a.status'],
    join: [
      {
        entity: UserInfoEntity,
        alias: 'user',
        condition: 'user.id = a.userId',
        type: 'leftJoin',
      },
      {
        entity: PayOrderEntity,
        alias: 'order',
        condition: 'order.id = a.orderId',
        type: 'leftJoin',
      },
    ],
    select: [
      'a.*',
      'user.nickName as userNickName',
      'user.phone as userPhone',
      'order.title as orderTitle',
      'order.orderNo as orderNo',
    ],
  },
})
export class AdminPayPaymentController extends BaseController {}